<?php
/**
 * Classe che implementa l'interfaccia \Syrius\Adapter\Driver e nascone mysqli
 * @package Adapter
 * @author <domenico.biancardi@gmail.com>
 */

namespace Syrius\Adapter;

class Mysql extends \Mysqli implements Driver {

	/**
	 * Effettua la connessione ad un database
	 * @param string $host
	 * @param string $database
	 * @param string $username
	 * @param string $password
	 * @param array $options
	 * @throws \Syrius\Exception\Connection_Error
	 */
	public function __construct($host, $database, $username, $password = "", $options = 0) {

		@parent::__construct($host, $database, $username, $password, $options);
		if ($this->connect_error) {
			throw new \Syrius\Exception\Connection_Error ('Connect Error (' . $this->connect_errno . ') ' . $this->connect_error);
		}
	}

	/**
	 * @see mysqli::select_db()
	 */
	public function select_db($dbname) {
		@parent::select_db($dbname);
		if ($this->connect_error) {
			throw new \Syrius\Exception\Connection_Error ('Connect Error (' . $this->connect_errno . ') ' . $this->connect_error);
		}
	}

}

?>
